import { createRouter, createWebHistory } from 'vue-router'

import layout from '@/views/layout/index.vue'
import login from '@/views/login/index.vue'
import home from '@/views/home/index.vue'
import category from '@/views/category/index.vue'
import subCategory from '@/views/subCategoty/index.vue'
import detail from '@/views/detail/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name:'layout',
      component:layout,
      children: [
        {
          path: '/home',
          name:'home',
          component:home,
        },
        {
          path: '/category/:id',
          name:'category',
          component:category,
        },
        {
          path: '/category/sub/:id',
          name:'subCategory',
          component:subCategory,
        },
        {
          path: '/detail/:id',
          name:'detail',
          component:detail,
        }
      ]
    },
    {
      path: '/login',
      name:'login',
      component: login
    }
  ],
  scrollBehavior () {
    return {
      top:0
    }
  }
})

export default router
